﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoolERP_BLL;
using CoolERP_Entities;

namespace CoolERP_Web.User
{
    public partial class YSKZD_SKD : BasePage
    {
        private Guid YSKZDID
        {
            get { return this.GetUrlParam("id") == null ? Guid.Empty : new Guid(this.GetUrlParam("id").ToString()); }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                BindData();
        }

        private void BindData()
        {
            double ysze=0;
            using (CW_YSKZDBLL xBLL = new CW_YSKZDBLL())
            {
                Dictionary<string, string> dc = new Dictionary<string, string>();
                dc.Add("ID", YSKZDID.ToString());
                int RecordCount = 0;
                YSKZDModel entity = xBLL.GetYSKZD(dc, "", null, 1, out RecordCount).FirstOrDefault();
                if (entity != null)
                {
                    liBH.Text = entity.BH.ToString();
                    liXSHTBH.Text = entity.XSHTBH.ToString();
                    liKHJC.Text = entity.KHJC;
                    liCZRYName.Text = entity.CZRYName;
                    liCJSJ.Text = entity.CJSJ.ToString("yyyy-MM-dd HH:mm");
                    liCKSJ.Text = entity.CKSJ.ToString("yyyy-MM-dd HH:mm");
                    liYSZE.Text = Convert.ToDouble(entity.YSZE).ToString();
                    liHB.Text = "元";
                    liZT.Text = Convert.ToInt32(entity.ZDZT) == 1 ? "完成" : "准备";
                    ysze=Convert.ToDouble(entity.YSZE);
                    liFPLXMC.Text = entity.FPLXMC;
                }
            }
            using (CW_SKD_FPBBLL cBLL = new CW_SKD_FPBBLL())
            {
                List<CW_SKD_FPBModel> mxbs = cBLL.GetSKDFPB(YSKZDID);
                GridView1.DataSource = mxbs;
                GridView1.DataBind();
                liMoney.Text = mxbs.Sum(t => t.FPJE).ToString("F");
                double wsje = ysze - mxbs.Sum(t => t.FPJE);
                liWSJE.Text = wsje.ToString();
            }
        }
    }
}